package com.zy.mc_module.wheel.recyclerview.divider;

import android.content.Context;
import android.graphics.Rect;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.zy.mc_module.utils.SizeUtils;

/**
 * Created on 18/12/22
 * 商城分割线
 */
public class ShopItemDivider extends RecyclerView.ItemDecoration {
    private Context context;

    public ShopItemDivider(Context context) {
        this.context = context;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        int position = parent.getChildAdapterPosition(view);
        if (position == 7) {
            outRect.left = SizeUtils.dp2px(context, 15);
            outRect.right = SizeUtils.dp2px(context, 3);
        }
        if (position == 8) {
            outRect.left = SizeUtils.dp2px(context, 3);
            outRect.right = SizeUtils.dp2px(context, 15);
        }
        if (position >= 9 && position % 2 != 0) {
            //左
            outRect.left = SizeUtils.dp2px(context, 15);
            // outRect.right = SizeUtils.dp2px(context, 15);
        }
        if (position >= 9 && position % 2 == 0) {
            //右
            outRect.left = SizeUtils.dp2px(context, 15) / 2;
            outRect.right = SizeUtils.dp2px(context, 15);
        }
    }
}
